home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
wctunits.zip
/
MOUSE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-08-03
|
26KB
|
821 lines
UNIT Mouse;
{ Mouse unit for Turbo Pascal.
The comments in this unit were basically copied directly
from the Advanced MS Dos Programing book, the section on
the Microsoft Mouse Driver, which was the source of all
the mouse interrupt functions and their parameters.
}
INTERFACE
USES
Dos;
CONST
LeftButton = 1;
RightButton = 2;
CenterButton = 4;
AnyButton = 7;
var
mouseon: boolean;
PROCEDURE InitMouse(VAR Buttons : word; VAR Err : boolean);
{ Initializes the mouse driver.
Call: nothing
Returns: Buttons = number of mouse buttons
Err = false if mouse support is available, true otherwise
Note: * After a call to this function the driver is initialized to the
following state:
- Mouse pointer at screen center and hidden.
- Display page is set to zero.
- Mouse pointer shape set to default arrow shape in graphics modes,
or reverse block in text modes.
- User mouse event handlers are disabled.
- Light pen emulation enabled.
- Mouse sensitivity set to default vales (see SetMouseSense)
- Pointer limits set to entire screen.
- Set mouseon to false
}
PROCEDURE Showmouse;
{ Displays the mouse pointer, and cancels any pointer exclusion area. }
PROCEDURE Hidemouse;
{ Removes the mouse pointer from the screen, but continues to track the
position of the mouse. }
FUNCTION ButtonPressed(Mask : word) : boolean;
{ Returns a true value if the specified button(s) is pressed.
Call: Mask = bit mask of desired button(s)
bit(s) Significance(if set)
0 left button
1 right button
2 center button
3-15 reserved(0)
: True is button is pressed, false otherwise.
Note: * The constants LeftButton, RightButton, CenterButton, and
AnyButton can be used for the bit masking. They equal 1, 2,
4, and 7 respectivly.
}
PROCEDURE GetMousePosition(VAR Buttons, Horiz, Vert : word);
{ Returns the current mouse button status and pointer position.
Call: nothing
Returns: Buttons = mouse button status
Horiz = horizontal (X) coordinate
Vert = vertical (Y) coordinate
Note: * Coordinates are in pixels regardless of the current display mode.
Position (0,0) is the upper left corner of the screen.
}
FUNCTION MouseIn(x1,y1,x2,y2: word):boolean;
{ Returns true if mouse is within rectangle with upper-left
corner (x1,y1) and lower-right corner (x2,y2).
}
PROCEDURE SetPointerPosition(Horiz, Vert : word);
{ Set the position of the pointer. The pointer is displayed in the new
position unless it has been hidden using HidePointer or it is an exclusion
area defined by SetPointerExcl.
Call: Horiz = horizontal (X) coordinate
Vert = vertical (Y) coordinate
Returns: nothing
Notes: * Coordinates are in pixels regardless of the current display mode.
Position (0,0) is the upper left corner of the screen.
* The position is adjusted if necessary to lie within the pointer
limits set by SetLimits.
}
PROCEDURE GetPressInfo(Button : word;
VAR Stat, Count, Horiz, Vert : word);
{ Returns the current status of all mouse buttons, and the number of presses
and position of the last press for a specifed mouse button since the last
call to this procedure for that button. The press counter for the button
is reset to zero.
Call: Button = button identifier
0 = left button
1 = right button
2 = center button
: Stat = button status
bit(s) Significance(if set)
0 left button is down
1 right button is down
2 center button is down
3-15 reserved(0)
Count = button press counter
Horiz = horizontal (X) coordinate of last button press
Vert = vertical (Y) coordinate of last button press
}
PROCEDURE GetReleaseInfo(Button : word;
VAR Stat, Count, Horiz, Vert : word);
{ Returns the current status of all mouse buttons, and the number of releases
and position of the last release for a specifed mouse button since the last
call to this procedure for that button. The release counter for the button
is reset to zero.
Call: Button = button identifier
0 = left button
1 = right button
2 = center button
Returns: Stat = button status
bit(s) Significance(if set)
0 left button is down
1 right button is down
2 center button is down
3-15 reserved(0)
Count = button release counter
Horiz = horizontal (X) coordinate of last button release
Vert = vertical (Y) coordinate of last button release
}
PROCEDURE SetLimits(HorMin, HorMax, VerMin, VerMax : word);
{ Limits the mouse pointer to stay within a certian area.
Call: HorMin = Minimum horizontal (X) coordinate
HorMax = Maximum horizontal (X) coordinate
VerMin = Minimum vertical (Y) coordinate
VerMax = Maximum vertical (Y) coordinate
Returns: nothing
Note: * If both HorMin and HorMax are zero then then the previous
horizontal limits remain unchanged; the same is true for
VerMin and VerMax.
}
PROCEDURE SetPointerShape(Horiz, Vert : word; Buffer : pointer);
{ Defines the shape, color, and hot spot of the pointer in graphics modes.
Call: Horiz = hot spot offset from the left
Vert = hot spot offset from the top
Buffer = pointer to mouse pointer image buffer
Returns: nothing
Note: * The pointer image buffer is 64 bytes long. The first 32 bytes
contain a bit mask which is ANDed with the screen image, and the
remaining 32 bytes are then XORed with the screen image.
* The hot spot is relative to the upper left corner of the pointer
image, and each offset must be in the range -16 to 16. In display
modes 4 and 5, the horizontal offset must be an even number.
}
PROCEDURE SetTextPointer(PtrTyp, AND_Str, XOR_End : word);
{ Defines the shape and attributes of the mouse pointer in text modes.
Call: PtrTyp = pointer type
0 = software cursor
1 = hardware cursor
AND_Str = AND mask value (if PtrTyp = 0) or starting line for
cursor (if PtrTyp = 1)
XOR_End = XOR mask value (if PtrTyp = 0) or ending line for
cursor (if PtrTyp = 1)
Returns: nothing
Notes: * If the software text cursor is selected, the masks in AND_Str and
XOR_End are mapped as follows:
Bit(s) Significance
0-7 character code
8-10 foreground color
11 intensity
12-14 background color
15 blink
For Example, the following call would yeild a software cursor
that inverts the foreground and background colors:
SetTextPointer(0, $77FF, $7700);
* When the hardware text cursor is selected, the values in AND_Str
and XOR_End are the starting and ending lines for the blinking
cursor generated by the video adapter. The maximum scan line
depends on the type of adapter and the current display mode.
}
PROCEDURE GetMotionCount(VAR Horiz, Vert : word);
{ Returns the net mouse displacement since the last call to this procedure.
The returned value is in mickeys; a positive number indicates travel to the
right or downwards, a negative number indicates travel to the left or
upwards. One mickey represents approximately 1/200 of an inch of mouse
movement.
Call: nothing
Returns: Horiz = horizontal (X) mickey count
Vert = vertical (Y) mickey count
}
PROCEDURE SetEventHandler(EventMask : word; Handler : pointer);
{ Sets the address and event mask for an application program's mouse event
handler. The handler is called by the mouse drvier whenever the specifed
mouse events occur.
Call: EventMask = event mask
Bit(s) Significance(if set)
0 mouse movement
1 left button pressed
2 left button released
3 right button pressed
4 right button released
5 center button pressed
6 center button released
7-15 reserved(0)
Handler = Pointer to the handler procedure
Returns: nothing
Notes: * The user-defined handler is entered from the mouse driver by a
far call with the registers